package com.rbs.service.Impl;

import com.rbs.dao.BrandDao;
import com.rbs.entity.Brand;
import com.rbs.service.BrandService;
import com.rbs.util.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.ArrayList;
import java.util.List;


public class BrandServiceImpl implements BrandService {

    @Override
    public List<Brand> selectAllBrand() {
        //调用dao
        //现获取dao对象
        //现获取连接
        SqlSession sqlSession =null;
        List<Brand> brandList = null;
        try {
            sqlSession = MybatisUtils.getSession();
            BrandDao brandDao = sqlSession.getMapper(BrandDao.class);
            brandList = brandDao.selectAll();
            sqlSession.commit();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            MybatisUtils.closeSession(sqlSession);
        }
        return brandList;
    }
}
